package com.zm.openapi.model;

import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

@Data
@ToString
public class SimpleApiResult {

//    @ApiModelProperty(value = "结果状态码,0表示调用成功，非0表示调用失败", dataType = "String")
    private String code = "0";

    private String msg = "成功";

    private String hiddenMsg;

    public SimpleApiResult() {
    }

    public SimpleApiResult(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public SimpleApiResult(IResultEnum myEnum, String extraErrorMsg, String hiddenMsg) {
        if (myEnum != null) {
            this.code = myEnum.getCode();
            this.msg = myEnum.getMsg();
        }
        if (StringUtils.isNotBlank(extraErrorMsg)) {
            this.msg = this.msg + ", " + extraErrorMsg;
        }
        this.hiddenMsg = hiddenMsg;
    }

    public boolean isSuccess() {
        return "0".equals(code);
    }
}
